package com.boot.repository;

import com.boot.entity.Major;
import com.boot.entity.School;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;


import javax.transaction.Transactional;
import java.util.List;

@Repository
@Transactional
public interface MajorRepository extends JpaRepository<Major, Integer>, JpaSpecificationExecutor<Major> {

    @Query(value = "select m from Major m  where m.majorName like concat('%',?1,'%') ")
    List<Major> findAllByMajorNameLike(String majorName);

    List<Major> findAllBySchoolId(Integer schoolId);
    void deleteBySchoolId(Integer schoolId);
    Major findByMajorId(Integer majorId);
    Major findByMajorName(String name);
    Boolean existsBySchoolId(Integer id);
    Boolean existsByMajorId(Integer id);
}
